package com.example.demo.niuke;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Author: liull
 * @Description:编写一个函数，传入一个int型数组，返回该数组能否分成两组， 使得两组中各元素加起来的和相等，
 * 并且，所有5的倍数必须在其中一个组中，
 * 所有3的倍数在另一个组中（不包括5的倍数），能满足以上条件，返回true；不满足时返回false。
 * @Date: Created in 13:03 2020/3/25
 * @Modified By:
 */
public class Main34 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while ((line = br.readLine()) != null) {
            int number = Integer.parseInt(line);
            String readLine = br.readLine();
            List<Integer> list = Stream.of(readLine.split(" ")).map(i -> Integer.parseInt(i)).collect(Collectors.toList());
            list.forEach(it -> {

            });
            // 5的倍数
            List<Integer> a = new ArrayList<>();
            // 3的倍数
            List<Integer> b = new ArrayList<>();
            // 其它
            List<Integer> c = new ArrayList<>();
            for (int i = 0; i < list.size(); i++) {
                if (list.get(i) % 5 == 0) {
                    a.add(list.get(i));
                } else if (list.get(i) % 3 == 0) {
                    b.add(list.get(i));
                } else {
                    c.add(list.get(i));
                }
            }
            if (c.isEmpty()) {
                int countA = a.stream().mapToInt(i -> i).sum();
                int countB = b.stream().mapToInt(i -> i).sum();
                System.out.println(countA == countB);
            } else if (a.isEmpty()) {
                int countA = c.stream().mapToInt(i -> i).sum();
                int countB = b.stream().mapToInt(i -> i).sum();
                System.out.println(countA == countB);
            } else if (b.isEmpty()) {
                int countA = a.stream().mapToInt(i -> i).sum();
                int countB = c.stream().mapToInt(i -> i).sum();
                System.out.println(countA == countB);
            } else {
                int countA = a.stream().mapToInt(i -> i).sum();
                int countB = b.stream().mapToInt(i -> i).sum();
                int countC = c.stream().mapToInt(i -> i).sum();
                if (countA == countB + countC || countB == countA + countC) {
                    System.out.println(true);
                } else
                    System.out.println(false);
            }
        }
    }
}
